// 不自创form，嵌入在其他form内部，所以需要传入form


import { Form, Select } from 'antd';
import React from 'react';
import { list2filters } from '../../utils/form';

export const FilterForm = props => {
  const {
    title,
    field,

    form,

    init, // 初始值

    enums, // dic.dic.brand_contract_status
    mapping = {
      value: 'enum_value',
      desc: 'enum_desc'
    },
  } = props;


  return (
    <Form.Item label={title}>
      {form.getFieldDecorator(field, { initialValue: init })(
        <Select placeholder="请选择" style={{ width: 100 }}>
          {list2filters(enums, mapping.value, mapping.desc)}
        </Select>,
      )}
    </Form.Item>
  );
}